package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.EngineerLevel;
import com.shrcl.engineerprocess.domain.TSCPhase;
import com.shrcl.engineerprocess.domain.TSCWorkLoadType;
import com.shrcl.engineerprocess.domain.TSCWorkLoadTypeDAO;
import com.shrcl.engineerprocess.domain.impl.TSCWorkLoadTypeImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import java.util.Collection;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.TSCWorkLoadTypeDAO")
public class TSCWorkLoadTypeDAOImpl extends BaseDAOService<TSCWorkLoadType> implements TSCWorkLoadTypeDAO {
  public TSCWorkLoadType create(final Procedure1<? super TSCWorkLoadType> init) {TSCWorkLoadType tSCWorkLoadType=TSCWorkLoadTypeImpl.create(getObjectFactory());
    final Procedure1<TSCWorkLoadType> _function = new Procedure1<TSCWorkLoadType>() {
        public void apply(final TSCWorkLoadType it) {
          init.apply(it);
        }
      };
    TSCWorkLoadType _doubleArrow = ObjectExtensions.<TSCWorkLoadType>operator_doubleArrow(tSCWorkLoadType, _function);
    return _doubleArrow;
  }
  
  public Collection<TSCWorkLoadType> getAllTSCWorkLoadType() {IGenericQuery<TSCWorkLoadType> query=getObjectFactory().createGenericQuery(TSCWorkLoadType.class,"select e from com.shrcl.engineerprocess.domain.impl.TSCWorkLoadTypeImpl as e   where  e.active = 1      ");
    Collection<TSCWorkLoadType> _list = query.list();
    return _list;
  }
  
  public void delete(final TSCWorkLoadType workLoadType) {getObjectFactory().delete(workLoadType);
    
  }
  
  public void obsolete(final TSCWorkLoadType workLoadType) {
    workLoadType.setIsActive(Boolean.valueOf(false));
  }
  
  public void recover(final TSCWorkLoadType workLoadType) {
    workLoadType.setIsActive(Boolean.valueOf(true));
  }
  
  public Collection<TSCWorkLoadType> getTSCWorkLoadType(final TSCPhase phase, final EngineerLevel engineerLevel) {
    IGenericQuery<TSCWorkLoadType> query=getObjectFactory().createGenericQuery(TSCWorkLoadType.class,"select e from com.shrcl.engineerprocess.domain.impl.TSCWorkLoadTypeImpl as e   where (((e.phase) = (:phase)) and ((e.engineerLevel) = (:engineerLevel))) and  e.active = 1      ").setParameter("phase",phase).setParameter("engineerLevel",engineerLevel);
    Collection<TSCWorkLoadType> _list = query.list();
    return _list;
  }
}
